<template>
  <div class="custom-play">
    <transition
      name="custom-classes-transition"
      enter-active-class="animated fadeInUp"
      leave-active-class="animated fadeOutDown"
    >
      <PlayBar
        v-if="currentSong && showPlayBar"
        :currentSong="currentSong"
        :playing="playing"
        :currentTime="currentTime"
        :duration="duration"
        @audio-play-handler="$emit('audio-play-handler')"
        @audio-pause-handler="$emit('audio-pause-handler')"
        @click.native="showPlayBar = false"
      ></PlayBar>
    </transition>
    <transition
      name="custom-classes-transition"
      enter-active-class="animated fadeIn"
      leave-active-class="animated fadeOut"
    >
      <PlayPage
        v-if="currentSong && !showPlayBar"
        @hide-play-page="showPlayBar = true"
        :currentSong="currentSong"
        :playing="playing"
        :currentTime="currentTime"
        :duration="duration"
        @update:currentTime="$emit('update:currentTime', $event)"
        @audio-play-handler="$emit('audio-play-handler')"
        @audio-pause-handler="$emit('audio-pause-handler')"
        :currentPlayList="currentPlayList"
        @update:currentSong="$emit('update:currentSong', $event)"
        @prev-song="$emit('prev-song')"
        @next-song="$emit('next-song')"
      ></PlayPage>
    </transition>
    <MyPlayList
      v-if="showMyPlayList"
      :currentPlayList="currentPlayList"
      @update:currentSong="$emit('update:currentSong', $event)"
      :currentSong="currentSong"
    ></MyPlayList>
  </div>
</template>

<script>
import MyPlayList from "./MyPlayList.vue";
import PlayBar from "./PlayBar.vue";
import PlayPage from "./PlayPage.vue";
export default {
  components: { PlayBar, PlayPage, MyPlayList },
  props: {
    currentSong: Object,
    playing: Boolean,
    currentTime: Number,
    duration: Number,
    currentPlayList: Array,
  },
  data() {
    return {
      showPlayBar: true,
      showMyPlayList: false,
    };
  },
};
</script>

<style>
</style>